/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.ControlEscolar.Services;



import com.ControlEscolar.Beans.Curriculum;
import com.ControlEscolar.DAOs.CurriculumDAO;
import com.ControlEscolar.DAOs.DAOException;
import com.ControlEscolar.Exceptions.AlreadyExistExp;
import com.ControlEscolar.Exceptions.ServiceExp;
import com.ControlEscolar.Validations.ValidationsCurriculum;
import java.util.ArrayList;



/**
 *
 * @author Rodna Marrufo
 */
public class CurriculumService {

    ValidationsCurriculum validationCurriculum = new ValidationsCurriculum();
    CurriculumDAO curriculumDAO=new CurriculumDAO();

    public void createCurriculum(Curriculum curriculum) throws  AlreadyExistExp, ServiceExp{
     try{
        if(validationCurriculum.isExistCurriculum(curriculum.getCurriculumName())){
              throw new AlreadyExistExp("YA EXISTE ESE DATO");
          }       
         else
              curriculumDAO.add(curriculum);
      }catch(DAOException e){
         throw new ServiceExp();
     }
   }

    public int getTotalNumOfSemesters(String ID_Curriculum) throws ServiceExp {
      try{
        Curriculum curriculum = curriculumDAO.queryByID(ID_Curriculum);
        return curriculum.getTotalSemester();
      }
        catch(DAOException e){
            throw new ServiceExp();
        }
    }

    public ArrayList<Curriculum> getCurriculumList() throws ServiceExp {
        try{
        return curriculumDAO.query();}
        catch(DAOException e){
            throw new ServiceExp();
        }
    }

}
